package com.jming.jike.dto.backend;


import com.jming.jike.common.ValidatorGroup.Insert;
import com.jming.jike.common.ValidatorGroup.Update;
import com.jming.jike.dto.BaseDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2022/04/19
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SetMealDTO extends BaseDTO {

    @ApiModelProperty(value = "套餐主键id")
    @NotNull(message = "套餐id不能为空", groups = {Update.class})
    @Min(value = 1, message = "套餐id最小为{value}", groups = {Update.class})
    private Long id;

    @ApiModelProperty(value = "套餐名称")
    @NotBlank(message = "套餐名称不能为空", groups = {Insert.class, Update.class})
    @Length(max = 30, message = "套餐名称不能超过{max}个字符", groups = {Insert.class, Update.class})
    private String name;

    @ApiModelProperty(value = "套餐分类id")
    @NotNull(message = "套餐分类id不能为空", groups = {Insert.class, Update.class})
    private Long categoryId;

    @ApiModelProperty(value = "套餐价格")
    @NotNull(message = "套餐价格不能为空", groups = {Insert.class, Update.class})
    @DecimalMin(message = "套餐价格不能小于0.01", value = "0.01", groups = {Insert.class,  Update.class})
    @DecimalMax(message = "套餐价格不能大于99999.99", value = "99999.99", groups = {Insert.class, Update.class})
    private BigDecimal price;

    @ApiModelProperty(value = "图片")
    @NotBlank(message = "图片不能为空", groups = {Insert.class, Update.class})
    private String image;

    @ApiModelProperty(value = "图片地址")
    @NotBlank(message = "图片地址不能为空", groups = {Insert.class, Update.class})
    private String imageUrl;

    @ApiModelProperty(value = "描述信息")
    @Length(max = 200, message = "描述不能超过{max}个字符", groups = {Insert.class, Update.class})
    private String description;

    @ApiModelProperty(value = "顺序")
    private Integer sort;

    @Valid
    @ApiModelProperty("菜品列表")
    @NotEmpty(message = "菜品列表不能为空", groups = {Insert.class, Update.class})
    private List<SetMealDishDTO> setMealDishDTOList;

}
